import i18n from '@/locale';

function transformOptions(options: any[]) {
    return options.reduce((res, item) => {
        res[item.value] = item.label;
        return res;
    }, {} as Record<string, string>);
}
export const DATA_TYPE = {
    INTEGER: 'integer',
    DECIMAL: 'decimal',
    STRING: 'string',
    BOOLEAN: 'bool',
    ENUM: 'enum',
};
export const DATA_TYPE_OPTIONS = [
    {
        label: i18n.global.t('zheng-shu'),
        value: DATA_TYPE.INTEGER,
    },
    {
        label: i18n.global.t('xiao-shu'),
        value: DATA_TYPE.DECIMAL,
    },
    {
        label: i18n.global.t('zi-fu-chuan'),
        value: DATA_TYPE.STRING,
    },
    {
        label: i18n.global.t('bu-er'),
        value: DATA_TYPE.BOOLEAN,
    },
    {
        label: i18n.global.t('mei-ju'),
        value: DATA_TYPE.ENUM,
    },
];
export const ProductTypeOptions = [
    {
        label: i18n.global.t('wang-guan-she-bei'),
        value: '1',
    },
    {
        label: i18n.global.t('wang-guan-zi-she-bei'),
        value: '2',
    },
];
export const ProductCategoryOptions = [
    {
        label: i18n.global.t('wang-guan-lei'),
        value: '10',
    },
    {
        label: i18n.global.t('jia-zhu-lei'),
        value: '20',
    },
    {
        label: i18n.global.t('ya-suo-ji-lei'),
        value: '30',
    },
    {
        label: i18n.global.t('xie-qi-beng'),
        value: '40',
    },
    {
        label: i18n.global.t('an-quan-lei'),
        value: '50',
    },
];

export const ProductTypeDict = transformOptions(ProductTypeOptions);
export const ProductCategoryDict = transformOptions(ProductCategoryOptions);
export const StatusDict = {
    0: i18n.global.t('disable'),
    1: i18n.global.t('enable'),
};

export const AlertStatusDict = {
    0: '未知',
    2: i18n.global.t('disable'),
    1: i18n.global.t('enable'),
};

export const AlertStatusOptions = [
    {
        label: AlertStatusDict[1],
        value: 1,
    },
    {
        label: AlertStatusDict[2],
        value: 2,
    },
];
